//
// Created by 崔世强 on 2018/5/17.
// Copyright (c) 2018 Facebook. All rights reserved.
//

import Foundation
import WCDBSwift


final class UserSetting:TableCodable {
    static let table = "user_setting"

    var chatOpen:Bool = false                   //是否开启聊天功能
    var speakerOff:Bool = false                 //听筒模式是否开启，默认关闭
    var globalGroupNickName:String?             //全局群组昵称
    var globalGroupNoDisturb:Bool = false       //全局群聊消息免打扰
    var globalSingleNoDisturb:Bool = false      //全局单聊消息免打扰
    var lastUpdTime:Date = Date()               //最近更新时间

    enum CodingKeys: String, CodingTableKey {
        typealias Root = UserSetting
//        static let objectRelationalMapping = TableBinding(CodingKeys.self)
        case chatOpen = "chat_open"
        case speakerOff = "speaker_off"
        case globalGroupNickName = "global_group_nickname"
        case globalGroupNoDisturb = "global_group_no_disturb"
        case globalSingleNoDisturb = "global_single_no_disturb"
        case lastUpdTime = "last_upd_time"
        
        static let objectRelationalMapping = TableBinding(CodingKeys.self) {
            BindColumnConstraint(.chatOpen, defaultTo: false)
            BindColumnConstraint(.speakerOff, defaultTo: false)
            BindColumnConstraint(.globalGroupNoDisturb, defaultTo: false)
            BindColumnConstraint(.globalSingleNoDisturb, defaultTo: false)
        }

//        static var columnConstraintBindings: [CodingKeys: ColumnConstraintBinding]? {
//            return [
//                .chatOpen:ColumnConstraintBinding(defaultTo: false),
//                .speakerOff:ColumnConstraintBinding(defaultTo: false),
//                .globalGroupNoDisturb:ColumnConstraintBinding(defaultTo: false),
//                .globalSingleNoDisturb:ColumnConstraintBinding(defaultTo: false),
//            ]
//        }
    }

}
